// 接口文件
import axios from './request'

// 登陆接口 登陆页面请求
export const fetchLogin = ({ username, password }) => {
  return axios.post('/api/login', { username, password })
}

/**
 * @param [token-必传]
 *
 */
export const fetchUserInfo = (token) => {
  return Promise.resolve({
    code: 0,
    msg: 'success',
    data: {
      avatar: 'https://www.robohash.org/1',
      gender: 1,
      menus: [],
    },
  })
}
/**
 * @name [查数据]
 * @method [get]
 * @param [page, size]
 */

export const fetchList = ({ page = 1, size = 5 }) => {
  console.log('接口区域：', page, size)
  return axios.get('/api/country', { params: { page, size } })
}
/**
 * @name [增加数据接口]
 * @method [post]
 * @params [token, countryName，continent，nature]
 */
export const fetchAddItem = (data) => {
  return axios.post('/api/addItem', data)
}

/**
 * @name [修改数据接口]
 * @method [post]
 * @params [token, countryName，continent，nature]
 */
export const fetchUpdateItem = (data) => {
  return axios.post('/api/updateItem', data)
}

/**
 * @name [删除数据接口]
 * @method [post]
 * @params [token, id]
 */
export const fetchDeleteItem = ({ id }) => {
  console.log(id, 'id---->')
  return axios.get('/api/removeItem', {
    params: { id },
  })
}
